package com.x.attendance.core.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.x.base.core.entity.annotation.*;
import org.apache.openjpa.persistence.jdbc.Index;

import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.project.annotation.FieldDescribe;

/**
 * 考勤设备实体类
 * @author Manus AI
 */
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.AttendanceDevice.table, uniqueConstraints = {
		@UniqueConstraint(name = PersistenceProperties.AttendanceDevice.table + JpaObject.IndexNameMiddle
				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class AttendanceDevice extends SliceJpaObject {

	private static final long serialVersionUID = 1325197931747463981L;
	private static final String TABLE = PersistenceProperties.AttendanceDevice.table;

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@FieldDescribe("数据库主键,自动生成.")
	@Id
	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
	private String id = createId();

	@Override
	public void onPersist() {
	}

	/*
	 * =============================================================================
	 * ===== 以下为考勤设备字段
	 * =============================================================================
	 */

	public static final String deviceId_FIELDNAME = "deviceId";
	@FieldDescribe("设备编号")
	@Index(name = TABLE + IndexNameMiddle + deviceId_FIELDNAME)
	@Column(length = 100, name = ColumnNamePrefix + deviceId_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String deviceId;

	public static final String name_FIELDNAME = "name";
	@FieldDescribe("设备名称")
	@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
	@Column(length = length_255B, name = ColumnNamePrefix + name_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String name;

	public static final String type_FIELDNAME = "type";
	@FieldDescribe("设备类型")
	@Column(length = 50, name = ColumnNamePrefix + type_FIELDNAME)
	private String type;

	public static final String ipAddress_FIELDNAME = "ipAddress";
	@FieldDescribe("IP地址")
	@Column(length = 50, name = ColumnNamePrefix + ipAddress_FIELDNAME)
	private String ipAddress;

	public static final String port_FIELDNAME = "port";
	@FieldDescribe("端口号")
	@Column(name = ColumnNamePrefix + port_FIELDNAME)
	private Integer port;

	public static final String location_FIELDNAME = "location";
	@FieldDescribe("设备位置")
	@Column(length = length_255B, name = ColumnNamePrefix + location_FIELDNAME)
	private String location;

	public static final String status_FIELDNAME = "status";
	@FieldDescribe("设备状态")
	@Column(length = 50, name = ColumnNamePrefix + status_FIELDNAME)
	private String status;

	public static final String lastSyncTime_FIELDNAME = "lastSyncTime";
	@FieldDescribe("最后同步时间")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = ColumnNamePrefix + lastSyncTime_FIELDNAME)
	private Date lastSyncTime;

	public static final String enabled_FIELDNAME = "enabled";
	@FieldDescribe("是否启用")
	@Column(name = ColumnNamePrefix + enabled_FIELDNAME)
	private Boolean enabled;

	// Getters and Setters
	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Date getLastSyncTime() {
		return lastSyncTime;
	}

	public void setLastSyncTime(Date lastSyncTime) {
		this.lastSyncTime = lastSyncTime;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
}

